<?php

use think\migration\Seeder;

class AirQualityPollutantCompanyForecastHourData extends Seeder
{

    /**
     * 空气质量-站点-污染物-预报值 数据
     */
    public function run()
    {
        $table = $this->table('air_quality_pollutant_company_forecast_hour');

        $rows = [];
        $num = 168;
        $i = 0;
        while ($num > 0) {
            $typeArr = [
                ['id' => 1,'name' => 'PM2.5'],
                ['id' => 3,'name' => '二氧化硫'],
                ['id' => 4,'name' => '氮氧化物'],
            ];

            foreach ($typeArr as $k => $v) {
                $rows[] = [
                    //step1:时间
                    'predict_time'       => date('Y-m-d H', time() + 3600 * $i) . ':00:00',   //预报时间-7天168小时
                    'publish_time'       => date('Y-m-d H', time()) . ':00:00',                           //发布时间-7天168小时

                    //step2:贡献度相关
                    'contribution_name'  => $v['name'],    //贡献类型具体1PM2.5,3二氧化硫,4氮氧化物
                    'contribution_value' => mt_rand(100, 200),        //贡献度

                    //step:关联ID
                    'region_id'          => '53',             //区域ID
                    'station_id'         => mt_rand(1, 5),    //站点ID
                    'company_id'         => mt_rand(1, 2),    //公司ID

                    //step:关联ID
                    'industry_id'        => mt_rand(1, 2),      //行业1工业2非工业

                    //step:系统时间
                    'create_time'        => date('Y-m-d H:i:s', time()), //插入时间
                ];
                $num--;
                $i++;
            }

        }

        $table->insert($rows)->save();
    }
}